<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no, initial-scale=1" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta name="apple-mobile-web-app-status-bar-style"
	content="black-translucent" />
<meta content="telephone=no" name="format-detection" />
<title>申请确认</title>
<link rel="stylesheet" type="text/css"
	href="../../bdfpreloan/css/base.css" />
<!--自适应插件-->
<script type="text/javascript" src="../../bdfpreloan/js/FS.js"></script>
</head>

<body>
	<div class="fixBottom bgf fh2">
		<div class="wx-btn" onclick="submitForm();">提交</div>
	</div>
	<div class="wx-content">
		<div class="wx-tips-text">请向您的客户经理索取申请验证码</div>
		<form name='myForm' id="myForm" action="" method="post">
			<input type="hidden" name="protocolType" id="protocolType"/>
		
			<ul class="wx-formlist wx-formlist-noicon">
				<li class="wkbox">
					<div class="tl">企业名称</div>
					<div class="autoW tr cl3c wx-input-group">
						<input id="merchantName" type="text" readonly="readonly"
							th:value="${merchantName}" maxlength="30" />
					</div>
				</li>
				<li class="wkbox">
					<div class="tl">统一社会信用代码</div>
					<div class="autoW tr cl3c wx-input-group">
						<input id="licenseNo" type="text" th:value="${licenseNo}"
							readonly="readonly" maxlength="18" />
					</div>
				</li>
				<li class="wkbox">
					<div class="tl">客户经理手机号</div>
					<div class="autoW tr cl3c wx-input-group">
						<input id="phoneNo" type="tel" value="" maxlength="11" />
					</div>
				</li>
				<li class="wkbox">
					<div class=" tl">客户经理手机验证码</div>
					<div class="autoW tr cl3c wx-input-group">
						<input id="captcha" type="tel" placeholder="" maxlength="6" />
					</div>
					<div class="tr cllan ml10 getSMS">立即获取</div>
				</li>
			</ul>
			<div class="wx-link mt20 tl">
				<input id="checkbox" type="checkbox" checked="checked" /> <label
					for="checkbox"> <span class="cl6">本人已阅读并同意</span>
				</label> <a href="javascript:void(0);" onclick="showProtocal(0)">《老板贷注册及服务协议》</a>
			</div>
		</form>
	</div>
	<script src="../../bdfpreloan/vendor/jquery-2.1.3.min.js"></script>
	<script type="text/javascript" src="../../bdfpreloan/js/wx.js"></script>
	<script src="../../bdfpreloan/js/sendCode-new.js"></script>
	<script src="../../bdfpreloan/js/validate.js"></script>
	<script>
			$(function() {
				$('.getSMS').click(function() {
					if(isPhoneNo($('#phoneNo'))) {
						//发送授权码倒计时为60秒
						sends.count = 60;
						//定义重新发送按钮
						sends.obj = $('.getSMS');
						//封装参数 选中的银行卡信息等     13020171106
						var data =  {
					  		phoneNo: $('#phoneNo').val(),
					  		merchantName: $('#merchantName').val()
						};

// 						getSmsCode(data);
						sends.sendMessage('/bdfpreloan/loan/getSmsCode', data, callSuccess, errorfunc);											
					} else {
						validateError($('#phoneNo'), "请输入正确的手机号");
					}
				})
			})
			//发送成功
			function callSuccess(msg) {
				if(msg.success) {
					alert("发送成功");
				} else {
					alert(msg.message);
				}
			}
			//发送失败
			function errorfunc(msg) {
				sends.curCount = 0;
				alert('系统繁忙，请稍后再试')
			}
			
			function getSmsCode(date){
				$.ajax({　　
				   	type: "POST", //用方式传输
				　　	dataType: "JSON", //数据格式:JSON
				　　	url: '/bdfpreloan/loan/getSmsCode', //目标地址
				　　	data: {	
				  		phone: $('#phoneNo').val(),
					},
				　　	error: function(XMLHttpRequest, textStatus, errorThrown) {
						alert('系统异常');
						sends.curCount = 0;
						return false;
					},
				　　	success: function(data) {
// 				　　		return data;
				　　		if(data.code=='000000'){
				  			$("#captcha").val(null);
				  			alert("发送成功");
				  			sends.sendMessage('../../bdfpreloan/ajax_tpl/success.js', data, callSuccess, errorfunc);
				  		}else{	
				  			alert('获取失败，请稍后重试');
				  		}
					}
				});	
			}
			//初始化表单校验规则 v1.0 by wangxiang3
			validate.init({
				rules: {
					phoneNo: {
						required:true,
						phone:true
					},
					captcha:{
						required: true,
						length: 6
					}
				},
				messages: {}
			})
			function showMore(obj) {
				if ($(obj).val() == '20') {
					$('.mateInfo').show();
					$('.mateInfodesc').hide();
				} else {
					$('.mateInfo').hide();
					$('.mateInfodesc').show();
				}
			}
			function submitForm() {
				if (validate.submitForm()) {
					/* if ($('#sIDType').val()=='10100' && $('#sIDNO').val().length != 18) {
						alert('请输入正确的配偶身份证号');
						return false;
					} */
					var checked = true;
					$('input[type="checkbox"]').each(function() {
						if (!$(this).is(':checked')) {
							alert('请阅读并同意相关协议');
							checked = false;
						}
					})
					if (!checked) {
						return false;
					}
					$.ajax({　　
					   	type: "POST", //用POST方式传输
					　　	dataType: "JSON", //数据格式:JSON
					　　	url: '/bdfpreloan/loan/submitApply', //目标地址
					　　	data: {
					　　		captcha: $('#captcha').val(),
					  		phoneNo: $('#phoneNo').val(),
					  		merchantName: $('#merchantName').val(),
					  		licenseNo: $('#licenseNo').val(),
						},
					　　	error: function(XMLHttpRequest, textStatus, errorThrown) {
							alert('系统异常');
							return false;
						},
					　　	success: function(data) {	
					　　		//hideLoading();//去除遮罩
					  		if(data.code=='000000'){
					  			window.location= data.redirect;
					  		}else{
					  			//windows.location.href="www.baidu.com";
					  			alert(data.message)
					  		}
						}
					});
				}
			}
			
			//查看协议
			function showProtocal(type) {
				$('#protocolType').val(type);
				$("#myForm").attr("action", "bdfShowProtocol").submit();
			}
		</script>
</body>

</html>